﻿using RayDen.RayEngine.Core.Interface;
using RayDen.RayEngine.Core.Types;
using RayDen.RayEngine.Data;

namespace RayDen.RayEngine.Engines.ProgressivePhotonMapping {
    public class BasePPMPath : PathSamplerBase
    {
        protected RayEngineScene scene;
        protected PPMContext engine;

        protected int depth;

        protected float pathWeight;

        protected bool specularBounce;
        protected SurfaceIntersectionData hitInfo;

        public override void InitPath(IPathProcessor buffer)
        {
            base.InitPath(buffer);
            depth = 0;
            specularBounce = false;
            pathWeight = 1.0f;
            this.Sample = pathIntegrator.Sampler.GetSample(null);
            scene = pathIntegrator.Scene;             
            if (this.engine == null)
            {
                var ppb = buffer as PPMPathBuffer;
                this.engine = ppb.context;
            }
        }


        public override bool FillRayBuffer(RayBuffer rayBuffer)
        {
            var leftSpace = rayBuffer.LeftSpace();
            if((1 > leftSpace))
            {
                return false;
            }
            RayIndex = rayBuffer.AddRay(PathRay);
            return true;
        }
    }
}